/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


#if !defined(AFX_PGLPRINTER_H__F4E37980_AB9E_4336_86C8_C5868E0048AB__INCLUDED_)
#define AFX_PGLPRINTER_H__F4E37980_AB9E_4336_86C8_C5868E0048AB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLUtility.h>
#include <pgl/core/PGLRegion.h>

/*! \brief A printer interface

	This class provides an interface to printing methods. For example, you can use it inside a OnPrint function
	to print a region:

\code 
void CMyClass::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
	CPGLRegion* pRegion; // the region to print

	CPGLPrinter printer(pRegion);
	printer.Print(pDC, pInfo);

	// that's it !
}
\endcode

  \ingroup PGLBasicGroup
*/
class PGLCORE_EXT_CLASS CPGLPrinter  
{
public:
	//! \name Construtors
	//@{
	//! Default constructor
	CPGLPrinter(CPGLRegion* pRegion = NULL);
	//! Destructor
	virtual ~CPGLPrinter();
	//@}


	//! \name Setters and getters
	//@{
	//! Setting margins (in inches)
	void SetMargins(const CPGLRectF& rMargins)	{	m_rMargins = rMargins;};
	//! Return current margins (in inches)
	const CPGLRectF& GetMargins() const			{	return m_rMargins;};
	//@}

	//! \name Main Methods
	//@{
	/*! Prints the region

	\param pDC printer DC
	\param pInfo printing info. This object should have m_pPD element set.
	*/
	void Print(CDC* pDC, CPrintInfo* pInfo);
	//@}

protected:
	//! \name Attributes
	//@{
	//! region to print
	CPGLRegion* m_pRegion;
	//! margins (in inches)
	CPGLRectF m_rMargins;
	//@}

private:
	//! \name Methods
	//@{
	//! Prepares DC for printing
	void PreparePage();
	//! Compute dpi ratio
	double ComputeDpiRatio();
	//@}

	//! \name Attributes
	//@{
	//! Printer DC
	CDC* m_pPrinterDC;
	//! Print Info
	CPrintInfo* m_pPrintInfo;
	//@}
};

#endif // !defined(AFX_PGLPRINTER_H__F4E37980_AB9E_4336_86C8_C5868E0048AB__INCLUDED_)
